﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DataTimePicker控件
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void LabelShow()
        {
            label3.Text = "选择日期是本年度第" + dateTimePicker1.Value.DayOfYear.ToString() + "天";
            label4.Text = "选择日期是本周" + dateTimePicker1.Value.DayOfWeek.ToString();
            label5.Text = "两个日期相差" + Convert.ToString(Convert.ToInt32(dateTimePicker2.Value.Subtract(dateTimePicker1.Value).TotalDays)) + "天";
        }
        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            LabelShow();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            LabelShow();
        }

        private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
        {
            LabelShow();
        }
    }
}
